package com.zhumei.keyscale.weight;

public class Cmd
{
    public static String OPEN_MANY = "DE00F52BDF";
    public static String OPEN_ONE = "DE00F729DF";
    public static String OPEN_PEER = "DE00E53BDF";
    public static String OPEN_POOR = "DE00EF31DF";
    public static String OPEN_ZERO = "DE00E43ADF";
    public static String recovery = "DE01FA0124DF";
    public static String recovery_stat = "DE00FA24DF";
    public static String rever = "DE01E0043BDF";
    public static String set_card = "FFA15E03012C2D";
    public static String set_d = "DE01E3003CDF";
    public static String set_d_bl = "7E01E3003C7F";
    public static String set_ds = "DE00E33DDF";
    public static String set_ds_bl = "7E00E33D7F";
    public static String set_red_card = "FFA35C029393";
    public static String set_s = "DE01E3013DDF";
    public static String set_s_bl = "7E01E3013D7F";
    public static String set_start = "7E00E19F7F";
    public static String set_start_lc = "DE01E90137DF";
    public static String set_zljsd_start = "DE01E90137DF";
    public static String start_0 = "DE01E0013EDF";
    public static String start_2 = "DE01E0023DDF";
    public static String start_5 = "DE01E0033CDF";
    public static String start_6 = "DE01E0043BDF";
    
    public static String getLC(final int n, final int n2) {
        final String hexString = Integer.toHexString(n);
        final StringBuilder sb = new StringBuilder();
        sb.append("00000000");
        sb.append(hexString);
        final String string = sb.toString();
        final String substring = string.substring(string.length() - 6, string.length());
        final String hexString2 = Integer.toHexString(n2);
        final StringBuilder sb2 = new StringBuilder();
        sb2.append("00000000");
        sb2.append(hexString2);
        final String string2 = sb2.toString();
        final String substring2 = string2.substring(string2.length() - 4, string2.length());
        final StringBuilder sb3 = new StringBuilder();
        sb3.append("DE07E90001");
        sb3.append(substring);
        sb3.append(substring2);
        final StringBuilder sb4 = new StringBuilder();
        sb4.append("DE07E90001");
        sb4.append(substring);
        sb4.append(substring2);
        sb3.append(DataUtils.checkXor(sb4.toString()));
        sb3.append("DF");
        return sb3.toString();
    }
    
    public static String getWeight(final int n) {
        final String hexString = Integer.toHexString(n);
        final StringBuilder sb = new StringBuilder();
        sb.append("00000000");
        sb.append(hexString);
        final String string = sb.toString();
        final String substring = string.substring(string.length() - 2, string.length());
        final String substring2 = string.substring(string.length() - 4, string.length() - 2);
        final String substring3 = string.substring(string.length() - 6, string.length() - 4);
        final String substring4 = string.substring(string.length() - 8, string.length() - 6);
        final StringBuilder sb2 = new StringBuilder();
        sb2.append("DE05E000");
        sb2.append(substring);
        sb2.append(substring2);
        sb2.append(substring3);
        sb2.append(substring4);
        final StringBuilder sb3 = new StringBuilder();
        sb3.append("DE05E000");
        sb3.append(substring);
        sb3.append(substring2);
        sb3.append(substring3);
        sb3.append(substring4);
        sb2.append(DataUtils.checkXor(sb3.toString()));
        sb2.append("DF");
        return sb2.toString();
    }
    
    public static String getZljsd(String s) {
        final int n = (int)(Double.parseDouble(s) * 10000.0);
        final StringBuilder sb = new StringBuilder();
        sb.append("00000000");
        sb.append(n);
        s = sb.toString();
        final StringBuilder sb2 = new StringBuilder();
        sb2.append(s.substring(s.length() - 2, s.length()));
        sb2.append(s.substring(s.length() - 4, s.length() - 2));
        sb2.append(s.substring(s.length() - 6, s.length() - 4));
        sb2.append(s.substring(s.length() - 8, s.length() - 6));
        s = sb2.toString();
        final StringBuilder sb3 = new StringBuilder();
        sb3.append("DE06D102");
        sb3.append(s);
        sb3.append("04");
        final StringBuilder sb4 = new StringBuilder();
        sb4.append("DE06D102");
        sb4.append(s);
        sb4.append("04");
        sb3.append(DataUtils.checkXor(sb4.toString()));
        sb3.append("DF");
        s = sb3.toString();
        System.out.println(s);
        return s;
    }
}
